package com.tailyou.hms.firstapp.act;

import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.tailyou.hms.firstapp.R;
import com.tailyou.hms.firstapp.util.CommonUtils;

public class SelWdgActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sel_wdg);
        RadioGroup rgSex = findViewById(R.id.rgSex);
        rgSex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rbF:
                        showToast("性别：女");
                    case R.id.rbM:
                        showToast("性别：男");
                }
            }
        });
        CheckBox cbZ = findViewById(R.id.cbZ);
        cbZ.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                CommonUtils.showToast(SelWdgActivity.this, isChecked ? "喜欢足球" : "不喜欢足球");
            }
        });
        CheckBox cbL = findViewById(R.id.cbL);
        cbL.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                showToast(isChecked ? "喜欢篮球" : "不喜欢篮球");
            }
        });
        CheckBox cbP = findViewById(R.id.cbP);
        cbP.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                showToast(isChecked ? "喜欢排球" : "不喜欢排球");
            }
        });
        CheckBox cbB = findViewById(R.id.cbB);
        cbB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                showToast(isChecked ? "喜欢棒球" : "不喜欢棒球");
            }
        });

        Switch shLy = findViewById(R.id.shLy);
        shLy.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                showToast(isChecked ? "开" : "关");
            }
        });
    }

    private void showToast(String tipText) {
        Toast.makeText(SelWdgActivity.this, tipText, Toast.LENGTH_SHORT).show();
    }

}